﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace TjZheng.Example.MVC.Filter
{
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
    public class RainFilter : FilterAttribute, IActionFilter
    {
        //Filter优先级Score：Global>Controller>Action
        //AllowMultiple为true，相同Filter的优先级取决于Filter的Order大小，越小优先级越高
        //AllowMultiple为false，相同Filter的由Score决定，并只执行Score最低的Filter

        public RainFilter(string Identity)
        {
            this.Identity = Identity;
        }
        public RainFilter(string Identity, int Order)
        {
            this.Identity = Identity;
            this.Order = Order;
        }
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            filterContext.HttpContext.Response.Write(Identity + "_RainFilter.ActionExecuted<br/>");
        }

        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            filterContext.HttpContext.Response.Write(Identity + "_RainFilter.OnActionExecuting<br/>");
        }

        protected string Identity { get; set; }
    }

}